package com.liuhung.base.page;

import java.util.Date;

import org.apache.commons.lang.StringUtils;

public class BasePage {

	private Integer page = 1;//页码
	
	private Integer rows =10;//每页显示数目
	
	private Integer num =0;//总共多少条数目
	
	private String url;
	
	private String sort;
	
	private int order=0;//0 ASC升序 1 DESC降序
	
	
	private Date datecreated;
	private Date lastupdated;
	private java.lang.Integer  status =0;
	private java.lang.Integer deleted =0;

	
	/*************************************
	 * @return the datecreated
	 *************************************/
	public Date getDatecreated() {
		return datecreated;
	}

	/*****************************************
	 * @param datecreated the datecreated to set
	 *****************************************/
	public void setDatecreated(Date datecreated) {
		this.datecreated = datecreated;
	}

	/*************************************
	 * @return the lastupdated
	 *************************************/
	public Date getLastupdated() {
		return lastupdated;
	}

	/*****************************************
	 * @param lastupdated the lastupdated to set
	 *****************************************/
	public void setLastupdated(Date lastupdated) {
		this.lastupdated = lastupdated;
	}

	/*************************************
	 * @return the status
	 *************************************/
	public java.lang.Integer getStatus() {
		return status;
	}

	/*****************************************
	 * @param status the status to set
	 *****************************************/
	public void setStatus(java.lang.Integer status) {
		this.status = status;
	}

	/*************************************
	 * @return the deleted
	 *************************************/
	public java.lang.Integer getDeleted() {
		return deleted;
	}

	/*****************************************
	 * @param deleted the deleted to set
	 *****************************************/
	public void setDeleted(java.lang.Integer deleted) {
		this.deleted = deleted;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	/**
	 * 分页导航
	 */
	private Pager pager = new Pager();
	
	public Pager getPager() {
		pager.setPageId(getPage());
		pager.setPageSize(getRows());
		if(url!=null)
		pager.setUrl(url);
		if(num>0)
		{
			pager.setRowCount(num);
		}
		String orderField="";
		if(StringUtils.isNotBlank(sort)){
			orderField = sort;
		}
		
		pager.setOrderField(orderField);
		
		if(order==0)
		pager.setOrderDirection(true);
		else {
			pager.setOrderDirection(false);
		}
		
		return pager;
	}

	public void setPager(Pager pager) {
		this.pager = pager;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getRows() {
		return rows;
	}

	public void setRows(Integer rows) {
		this.rows = rows;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
}
